<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/3/14
 * Time: 11:28
 */

namespace iBrand\Shop\Backend\Http\Controllers;


use iBrand\Shop\Core\Repositories\UserShopRepository;
use Encore\Admin\Facades\Admin as LaravelAdmin;
use Encore\Admin\Layout\Content;

class UserController extends Controller
{
    protected $userShopRepository;

    public function __construct(UserShopRepository $userShopRepository)
    {
        $this->userShopRepository = $userShopRepository;
    }

    public function index()
    {
        $shop_id = session('shop_id');
        $users = $this->userShopRepository->getUserListByShopId($shop_id);

        return LaravelAdmin::content(function (Content $content) use ($users, $shop_id) {

            $content->header('会员管理');

            if (session()->has('shop_name')) {

                $content->description(session('shop_name'));
            }

            $content->breadcrumb(
                ['text' => '门店管理', 'url' => 'shop/list/store', 'no-pjax' => 1],
                ['text' => '会员管理', 'url' => '', 'no-pjax' => 1, 'left-menu-active' => '用户列表']
            );


            $content->body(view('shop-backend::users.index', compact('users', 'shop_id')));
        });
    }
}